function [M, N, out, dict] = MyEncode(I)
I=im2uint8(I);
[M,N] = size(I);
 I1 = I(:);
 P = zeros(1,256);
 %获取各符号的概率；
 for i = 0:255
     P(i+1) = length(find(I1 == i))/(M*N);
 end

 k = 0:255;
 dict = huffmandict(k,P); %生成字典
 enco = huffmanenco(I1,dict); %编码
 out=enco;
end